<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .container {
      display: flex;
    }

    .element {
      padding: 10px;
      margin-right: 10px;
      background-color: gray;
      cursor: pointer;
    }

    .title {
      margin: 0;
      padding: 0;
    }

    .image {
      display: none;
      max-width: 100px;
    }
.content{
  display: none;
}
    .active .content {
      display: block;
    }

    .active .image {
      display: block;
    }
  </style>
</head>

<body>

  <div class="container">
    <div class="element">
      <h3 class="title">第一个元素</h3>
      <img class="image" src="/src/img/product/DSC_0488.png" alt="">
      <p class="content">这是第一个元素对应的文字段落</p>
    </div>
    <div class="element">
      <h3 class="title">第二个元素</h3>
      <img class="image" src="/src/img/product/DSC_0488.png" alt="">

      <p class="content">这是第二个元素对应的文字段落</p>
    </div>
    <div class="element">
      <h3 class="title">第三个元素</h3>
      <img class="image" src="/src/img/product/DSC_0488.png" alt="">
      <p class="content">这是第三个元素对应的文字段落</p>
    </div>
    <div class="element">
      <h3 class="title">第四个元素</h3>
      <p class="content">这是第四个元素对应的文字段落</p>
    </div>
    <div class="element">
      <h3 class="title">第五个元素</h3>
      <p class="content">这是第五个元素对应的文字段落</p>
    </div>
  </div>
  <script>
    const elements = document.querySelectorAll('.element');

    elements.forEach(element => {
      element.addEventListener('mouseenter', () => {
        elements.forEach(el => el.classList.remove('active')); // 移除所有元素的active类
        element.classList.add('active'); // 给当前元素添加active类
      });
    });
  </script>
</body>

</html>